import pyautogui
import pynput


def test(str):
    print('hotkey activated')
    pyautogui.typewrite(str,interval=1)

def for_canonical(f):
    return lambda k: f(l.canonical(k))


hotkey = pynput.keyboard.HotKey(
    pynput.keyboard.HotKey.parse('<ctrl>+i'),
    test('测试')
)

with pynput.keyboard.Listener(
    on_press=for_canonical(hotkey.press),
    on_release=for_canonical(hotkey.release)
) as l:
    l.join()